import { ApiCall, WsConnection } from 'tsrpc';
import { ReqCommunicate, ResCommunicate } from "../../../shared/protocols/AMessages/Live/PtlCommunicate";
import { Live } from '../../../utils/Classes/Live';
import { Wsserver } from '../../../index';

export default async function (call: ApiCall<ReqCommunicate, ResCommunicate>) {
    // TODO
    const user = call.currentUser
    const live = Live.lives.find(live => live.courseId.equals(call.req.courseId))
    if(live){

        await live.sendTalk(user,call.req.talk,'talk')

        call.succ({})
    }
    else{
        call.error('直播不存在')
    }
}